<template>
    <el-dialog title="录入会议记录" :visible.sync="dialogFormVisible" width="700px">
        <el-form ref="formData" :rules="rules" :model="formData">
            <el-form-item prop="meetInfo">
                <quill-editor :option="{ form:formData,model:'meetInfo'}"></quill-editor>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button
                type="primary"
                @click="submitForm('formData')"
                size="small"
                :disabled="loading"
                :icon="loading?'el-icon-loading':'el-icon-circle-plus-outline'"
            >确定</el-button>
        </div>
    </el-dialog>
</template>
<script>
const ERR_OK = 200;
import quillEditor from "components/quill-editor/quill-editor";
export default {
    props: {},
    data() {
        return {
            pickerOptions: {
                disabledDate(time) {
                    return time.getTime() < Date.now() - 24 * 60 * 60 * 1000;
                }
            },
            formData: {
                userId: this.$store.getters.userId,
                visionDemandId: "",
                meetInfo: ""
            },
            rules: {
                meetInfo: [
                    {
                        required: true,
                        message: "请录入会议记录",
                        trigger: "blur"
                    }
                ]
            },
            dialogFormVisible: false,
            loading: false
        };
    },
    methods: {
        show(item) {

          this.getMeetInfoById(item.visionDemandId)

          this.formData.visionDemandId = item.visionDemandId
          this.dialogFormVisible = true
          if (this.$refs['formData']) {
            this.$refs['formData'].resetFields()
          }

        },
      getMeetInfoById(visionDemandId){
          this.$ajax({
            method: "get",
            url:
              this.GLOBAL.oaVisionDemand +
              "/visionDemand/getMeetInfoById?visionDemandId=" + visionDemandId,
            data: this.formData
          }).then(res => {
            this.loading = false;
            if (res.data.code === ERR_OK) {
              console.log(res.data)
              this.formData.meetInfo = res.data.data.meetInfo;
            } else {

            }
          });
        },
        submitForm(formName) {
            this.$refs[formName].validate(valid => {
                if (valid) {
                    this.loading = true;
                    this.$ajax({
                        method: "post",
                        url:
                            this.GLOBAL.oaVisionDemand +
                            "/visionDemandStatus/saveMeetInfoById",
                        data: this.formData
                    }).then(res => {
                        this.loading = false;
                        if (res.data.code === ERR_OK) {
                            this.$message.success(res.data.msg);
                            this.dialogFormVisible = false;
                            this.$emit("loadData");
                        } else {
                            this.$message.error(res.data.msg);
                        }
                    });
                } else {
                    return false;
                }
            });
        }
    },
    components: {
        quillEditor
    }
};
</script>
<style lang="stylus" scoped>
.el-form-item {
    margin-bottom: 10px;

    .el-date-editor {
        width: 100%;
    }
}
</style>
